#测试个人设置页面
from time import sleep
from common.Untils import WJDriver
from selenium.webdriver.common.by import By


class WJSetting:
    url = ""
    driver = ""

    def __init__(self):
        #WJLogin.WJLogin().LoginSuccess()
        self.url = "http://8.155.1.153:8081/system/setting"
        self.driver = WJDriver.driver
        self.driver.get(self.url)
        WJDriver.Login()
        #sleep(2)
        #点击系统管理
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/div/span/div").click()
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/ul/li[6]").click()

    def TestBySettingFunction(self):
        # self.driver.find_element(By.XPATH,"").send_keys()
        # self.driver.find_element(By.XPATH,"").click()

        #1.点击基本设置，全部填写
        self.driver.refresh()
            #输入姓名
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[1]/div/div[2]/div/div/span/input").send_keys("zzj24")
            #输入手机号
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[2]/div/div[2]/div/div/span/input").send_keys("111")
            #输入邮箱
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[3]/div/div[2]/div/div/span/input").send_keys("111")
            #输入个人简介
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[4]/div/div[2]/div/div/textarea").send_keys("111")
            #点击提交
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[5]/div[2]/button").click()
        print("个人设置页面：1正常")
        #2.点击基本设置，全部不填写
            #刷新页面
        self.driver.refresh()
            #点击提交
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div[1]/form/div[5]/div[2]/button").click()
        print("个人设置页面：2正常")
        #3.点击安全设置，点击账户密码修改，正确输入旧密码，新密码，确认密码
            #点击安全设置
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[1]/ul/li[2]").click()
            #点击修改
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div/div/ul/li/ul").click()
            #输入旧密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[1]/div/div[2]/div/div/span/input").send_keys("123456")
            #输入新密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div/span/input").send_keys("123456")
            #输入确认密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[3]/div/div[2]/div/div/span/input").send_keys("123456")
            #点击确定修改
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/div/div[2]/button").click()
        print("个人设置页面：3正常")
        #4.点击安全设置，点击账户密码修改，正确输入旧密码，新密码，错误输入确认密码
            #点击安全设置
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[1]/ul/li[2]").click()
            #点击修改
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div/div/ul/li/ul").click()
            #输入旧密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[1]/div/div[2]/div/div/span/input").send_keys("123456")
            #输入新密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div/span/input").send_keys("123456")
            #输入错误的确认密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[3]/div/div[2]/div/div/span/input").send_keys("1234567")
            #点击确定修改
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/div/div[1]/button").click()
        print("个人设置页面：4正常")
        #5.点击安全设置，点击账户密码修改，旧密码填写错误
            #点击安全设置
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[1]/ul/li[2]").click()
            #点击修改
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div/div/div[2]/div[2]/div/div/ul/li/ul").click()
            #输入错误的旧密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[1]/div/div[2]/div/div/span/input").send_keys("1234567")
            #输入新密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div/span/input").send_keys("123456")
            #输入确认密码
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[3]/div/div[2]/div/div/span/input").send_keys("123456")
            #点击确定修改
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/div/div[1]/button").click()
        print("个人设置页面：5正常")
        print("个人设置页面全部正常...................")


#         self.driver.quit()
# setting=WJSetting()
# setting.TestBySettingFunction()